<!-- 班级详情页 -->
<template>
	<view v-if="roleType == 1">
		<u-navbar :is-back="false" title="我的班级"></u-navbar>
		<!-- 主要内容 -->
		<view class="main2">
			<!-- 年级/班级 start -->
			<view class="head" @click="toList" hover-class="hover_class">
				<image src="../../static/icon/ClassIcon.png" mode=""></image>
				<view class="main_content">
					<view class="top">
						<text>一年級4班</text>
						<image src="../../static/icon/ListMore.png" mode=""></image>
					</view>
					<view class="total">
							<text class="item_num">學生：30人</text>
							<text class="item_num">家長：30人</text>
							<text class="item_num">科任老師：5人</text>
					</view>
				</view>
				
			</view>
			<!-- 年级/班级 end -->
	
			<!-- 微云服务 start -->
			<view class="service">
				<text>微雲服務</text>
				<!-- 微云服务投票 start -->
				<view class="service-box">
					<navigator url="../all-vote/all-vote" hover-class="none">
						<view class="service-item">
							<text>調查投票</text>
							<image src="../../static/images/Poll.png" mode=""></image>
						</view>
					</navigator>
					<!-- 微云服务投票 end -->
	
					<!-- 微云服务 教学资源 start -->
					<navigator url="../resource/resource" hover-class="none">
						<view class="service-item">
							<text>教學資料</text>
							<image src="../../static/images/Teaching.png" mode=""></image>
						</view>
					</navigator>
					<!-- 微云服务 教学资源 end -->
				</view>
			</view>
			<!-- 微云服务 end -->
	
	
		</view>
	</view>
	
	<view v-else-if="roleType == 2">
		<!-- 自定义导航栏 -->
		<!-- <view>
			<navbar></navbar>
		</view> -->
		<view>
			<view class="status_bar"></view>
			<view class="navBarBox">
				<view class="navBar">
					<!-- <view @click="bindPickerChange">选择班级</view> -->
					<picker :range="classNameList" :value="index" @change="bindPickerChange" :range-key="classList.id">
						<view>{{classList[index].name}}</view>
						<view class="triangle"></view>
					</picker>
				</view>
		
			</view>
		</view>

		<!-- 主要内容 -->
		<view class="main">
			<!-- 年级/班级 start -->
			<view class="head">
				<!-- 班级/邀请 start -->
				<view class="top">
					<view class="classes">
						<image src="../../static/icon/ClassIcon.png" mode=""></image>
						<text>{{classList[index].name}}</text>
					</view>

					<view class="invite" @click="add">
						<image src="../../static/icon/add.png" mode="" style="width: 40upx;height: 40upx;"></image>
						<text>邀請</text>
					</view>
				</view>
				<!-- 班级/邀请 end -->

				<!-- 班级/家长 人数  	科任老师 start -->
				<view class="bottom">
					<view class="total" @click="toList">
						<view class="sum">
							<view class="item_num">{{classList[index].studentNum}}</view>
							<view class="item_name">班級人數</view>
						</view>
						<view class="parents">
							<view class="item_num">{{classList[index].parentNum}}</view>
							<view class="item_name">家長人數</view>
						</view>
						<view class="teachers">
							<view class="item_num">{{classList[index].teacherNum}}</view>
							<view class="item_name">科任老師</view>
						</view>
					</view>
				</view>
				<!-- 班级/家长 人数  科任老师 end -->
			</view>
			<!-- 年级/班级 end -->

			<!-- 微云服务 start -->
			<view class="service">
				<text>微雲服務</text>
				<!-- 微云服务投票 start -->
				<view class="service-box">
					<navigator :url="'../vote/vote?className='+classList[index].name+'&classId='+classList[index].id"  hover-class="none">
						<view class="service-item">
							<text>調查投票</text>
							<image src="../../static/images/Poll.png" mode=""></image>
						</view>
					</navigator>
					<!-- 微云服务投票 end -->

					<!-- 微云服务 教学资源 start -->
					<navigator url="../resource/resource" hover-class="none">
						<view class="service-item">
							<text>教學資料</text>
							<image src="../../static/images/Teaching.png" mode=""></image>
						</view>
					</navigator>
					<!-- 微云服务 教学资源 end -->
				</view>
			</view>
			<!-- 微云服务 end -->


		</view>
	</view>
	
	
</template>
<!-- 班级详情页 -->
<!-- <template>
	
</template> -->

<script>

	export default {
		data() {
			return {
				roleType: 0,
				classNameList: [],
				classList:[
					{
						id:12,
						name:'2021一年1班',
						studentNum:'23',
						parentNum:'23',
						teacherNum:'6',
					},
				],
				index: 0
			}
		},
		onLoad() {
			this.roleType = uni.getStorageSync("roleType")
		},
		onShow() {
			if(this.roleType == 1){
				
			}else if(this.roleType == 2){
				this.getclassinfomation()
			}
		},
		methods: {
			getclassinfomation(){
				this.$myRequest({
					url:"/teacher/getclassinfomation/"+uni.getStorageSync('id'),
				}).then(res => {
					this.classList = res.data.data
					this.classNameList=[]
					this.classList.forEach(row => {
						this.classNameList.push(row.name)
					})
				})
			},
			bindPickerChange(e) {
				this.index = e.target.value
				
			},
			add() { //底部上拉菜单
				uni.showActionSheet({
					itemList: ['邀請學生', '邀請家長', '邀請老師'],
					success: function(res) {
						uni.navigateTo({
							// url:'../vote/vote'
						})
					},
					fail: function(res) {
						console.log(res.errMsg)
					}
				})
			},
			toList() {
				uni.navigateTo({
					url: '../classList/classList?id='+this.classList[this.index].id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
	}

	.main {
		padding: 0 20upx;
		.head {
			width: 100%;
			background-color: #FFFFFF;
			margin: 30upx auto;
			border-radius: 20upx;
			box-shadow: 0 0 20px #dadada;
		}
		
		.top {
			height: 120upx;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			padding: 30upx;
			font-size: 24upx;
			image {
				width: 80upx;
				height: 80upx;
				margin-right: 20upx;
				vertical-align: middle;
			}
		}
		
		
		.total {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			text-align: center;
			padding: 0 40upx 30upx 40upx;
		}
		
		.item_num {
			font-size: 50upx;
			font-weight: bold;
		}
		
		.item_name {
			color: #808080;
			font-size: 32upx;
			margin: 20upx 0;
		}
		
		.service>text::before {
			display: inline-block;
			content: '|';
			color: #007AFF;
			font-weight: 900;
		}
		
		.service>text {
			font-size: 36upx;
		}
		
		navigator {
			width: 100%;
			margin-top: 30upx;
		}
		
		.service-box {
			display: flex;
			flex-direction: row;
			justify-content: space-around;
		}
		
		.service-item {
			flex: 1;
			margin: 0 15upx;
			padding: 20upx 10upx;
			border-radius: 10upx;
			background-color: #FFFFFF;
			box-shadow: 0 0 20px #e9e9e9;
			text {
				/* line-height: 150upx; */
				margin-left: 18upx;
				font-size: 32upx;
				font-weight: bold;
			}
			image {
				width: 120upx;
				height: 120upx;
				margin-left: 40upx;
				vertical-align: middle;
			}
		}
	}

	
	
	//自定义导航栏样式
	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
		background-color: #FFFFFF;
	}
	
	.navBarBox {
		height: 30px;
		background-color: #FFFFFF;
		padding: 7px 3px;
	}
	
	.navBarBox .navBar {
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		line-height: 30px;
	}
	.navBar view{
		float: left;
	}
	
	.navBar .triangle {
		width: 0px;
		height: 0px;
		border-left: 6px solid transparent;
		border-right: 6px solid transparent;
		border-top: 8px solid #000000;
		border-bottom: 6px solid transparent;
		margin-top: 12px;
		margin-left: 8px;
	}

	.main2 {
		padding: 0 20upx;
		
		.head {
			background-color: #FFFFFF;
			display: flex;
			flex-direction: row;
			// justify-content: flex-end;
			align-items: center;
			margin: 30upx auto;
			padding: 30upx 0;
			border-radius: 20upx;
			box-shadow: 0 0 20px #dadada;
		
			image {
				width: 100upx;
				height: 100upx;
				vertical-align: middle;
				margin: 0 20upx;
			}
			.top{
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				margin-bottom: 20upx;
				text{
					font-size: 32upx;
					font-weight: bold;
				}
				image{
					width: 48upx;
					height: 48upx;
					position: absolute;
					top: 60upx;
					right: 10upx;
				}
			}
			.total{
				display: flex;
				flex-direction: row;
				justify-content: space-around;
				text{
					color: #8a8a8a;
					margin-right: 20upx;
				}
			}
		}
		
		.hover_class{
			opacity: .9;
			background-color: #eeeeee;
		}
		
		// 微云服务
		.service>text::before {
			display: inline-block;
			content: '|';
			color: #007AFF;
			font-weight: 900;
		}
		
		.service>text {
			font-size: 36upx;
		}
		
		navigator {
			width: 100%;
			margin-top: 30upx;
		}
		
		.service-box {
			display: flex;
			flex-direction: row;
			justify-content: space-around;
		}
		
		.service-item {
			flex: 1;
			margin: 0 15upx;
			padding: 20upx 10upx;
			border-radius: 10upx;
			background-color: #FFFFFF;
			box-shadow: 0 0 20px #e9e9e9;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			
			text {
				/* line-height: 150upx; */
				margin-left: 18upx;
				font-size: 32upx;
				font-weight: bold;
			}
		
			image {
				width: 120upx;
				height: 120upx;
				margin-left: 40upx;
				vertical-align: middle;
			}
		}
	}
	
	
</style>
